package io.kiki.sba.registry.store.jdbc.config;

import io.kiki.sba.registry.store.api.elector.LeaderElector;
import io.kiki.sba.registry.store.api.spring.SpringContext;
import io.kiki.sba.registry.store.jdbc.elector.MetaJdbcLeaderElector;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableConfigurationProperties
@ConditionalOnProperty(value = SpringContext.PERSISTENCE_PROFILE_ACTIVE, havingValue = SpringContext.META_STORE_API_JDBC, matchIfMissing = true)
public class JdbcElectorConfiguration {

    @Configuration
    public static class JdbcElectorBeanConfiguration {

        @Bean
        public LeaderElector leaderElector() {
            return new MetaJdbcLeaderElector();
        }
    }
}
